package com.usian.controller;

import com.usian.pojo.TbContent;
import com.usian.service.ContentService;
import com.usian.utils.AdNode;
import com.usian.utils.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chen
 * @date 2021/1/11 - 20:09 - 星期一
 * @project usian_parent
 * @package com.usian.controller
 * @by GGbomd猪猪侠
 */
@RestController
public class ContentController {

    @Autowired
    private ContentService contentService;

    /**
     * 根据分类查询内容
     * @param page 当前页
     * @param rows 每页显示几条数据
     * @param categoryId 分类的id
     * @return
     */
    @RequestMapping("/selectTbContentAllByCategoryId")
    public PageResult selectTbContentAllByCategoryId(@RequestParam Integer page,@RequestParam Integer rows,
                                                     @RequestParam Long categoryId){
        return contentService.selectTbContentAllByCategoryId(page,rows,categoryId);
    }

    /**
     * 根据分类添加内容
     * @param tbContent
     * @return
     */
    @RequestMapping("/insertTbContent")
    public Integer insertTbContent(@RequestBody TbContent tbContent){
        return contentService.insertTbContent(tbContent);
    }

    /**
     *  删除分类下的内容
     * @param ids
     * @return
     */
    @RequestMapping("/deleteContentByIds")
    public Integer deleteContentByIds(@RequestParam Long ids){
        return contentService.deleteContentByIds(ids);
    }

    /**
     * 查询首页大广告位
     * 操作 tb_content
     * @return
     */
    @RequestMapping("/selectFrontendContentByAD")
    public List<AdNode> selectFrontendContentByAD(){
        return this.contentService.selectFrontendContentByAD();
    }
}
